package com.estun.backroundManagementService;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@EnableSwagger2
@EnableWebSocket
@EnableScheduling
@EnableAsync
@EnableRetry
public class BackgroundManagementServiceApplication {

	public static void main(String[] args) {
		SpringApplication.run(BackgroundManagementServiceApplication.class, args);
	}


	/**
	 * 同时使用开启 websocket 和 spring 的定时任务注解 ，导致Bean工厂会返回一个空的定时任务Bean
	 * 自己创建一个Bean交给Spring IOC容器管理
	 */
	@Bean
	public TaskScheduler taskScheduler() {
		ThreadPoolTaskScheduler scheduling = new ThreadPoolTaskScheduler();
		scheduling.setPoolSize(10);
		scheduling.initialize();
		return scheduling;
	}
}
